package com.app.GoCuro;

import com.app.GoCuro.util.DatabaseInformation;
import com.app.GoCuro.util.LoginResponse;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class AvailableActionsActivity extends BaseActivity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.available_actions);
		final DatabaseInformation databaseInfo = (DatabaseInformation) getIntent()
				.getSerializableExtra("selected_database");
		final LoginResponse loginResponse = (LoginResponse) getIntent()
				.getSerializableExtra("curr_user");

		// handle adding a new item
		final Button addItemsButton = (Button) findViewById(R.id.add_new_item_button);
		addItemsButton.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// get the passed in database name

				// start the database actions activity
				Intent databaseActionsIntent = new Intent(
						AvailableActionsActivity.this,
						DatabaseActionsActivity.class);
				databaseActionsIntent.putExtra("selected_database",
						databaseInfo.getName());
				AvailableActionsActivity.this
						.startActivity(databaseActionsIntent);
			}
		});

		final Button viewItemsButton = (Button) findViewById(R.id.view_items_button);
		viewItemsButton.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent viewItemsIntent = new Intent(
						AvailableActionsActivity.this, ViewItemsActivity.class);
				viewItemsIntent.putExtra("selected_database", databaseInfo);
				viewItemsIntent.putExtra("curr_user", loginResponse);
				AvailableActionsActivity.this.startActivity(viewItemsIntent);
			}
		});
	}

}
